from time import *
file1 = open('m1_sorted.txt').readlines()
mas1 = list()
tms1 = time()
for j1 in range (len(file1)):
    mas1.append(int(file1[j1]))
N1 = len(mas1)
for i1 in range (N1-1):
    k1 = 0
    for g1 in range(N1-i1-1):
        if mas1[g1] > mas1[g1+1]:
            mas1[g1], mas1[g1+1] = mas1[g1+1], mas1[g1]
            k1 += 1
    if k1 == 0:
        break
tme1 = time()


file2 = open('m2_reverse.txt').readlines()
mas2 = list()
tms2 = time()
for j2 in range (len(file2)):
    mas2.append(int(file2[j2]))
N2 = len(mas2)
for i2 in range (N2-1):
    k2 = 0
    for g2 in range(N2-i2-1):
        if mas2[g2] > mas2[g2+1]:
            mas2[g2], mas2[g2+1] = mas2[g2+1], mas2[g2]
            k2 += 1
    if k2 == 0:
        break
tme2 = time()


file3 = open('m3_shuffle.txt').readlines()
mas3 = list()
tms3 = time()
for j3 in range (len(file3)):
    mas3.append(int(file3[j3]))
N3 = len(mas3)
for i3 in range (N3-1):
    k3 = 0
    for g3 in range(N3-i3-1):
        if mas3[g3] > mas3[g3+1]:
            mas3[g3], mas3[g3+1] = mas3[g3+1], mas3[g3]
            k3 += 1
    if k3 == 0:
        break
tme3 = time()

print('m1_sorted', int(round(tme1 - tms1, 2)*1000), 'milliseconds')
print('m2_reverse', int(round(tme2 - tms2, 2)*1000), 'milliseconds')
print('m3_shuffle', int(round(tme3 - tms3, 2)*1000), 'milliseconds')



